#include "StaticJavaLib.h"
#include "gc.h"
struct FieldAccessFoo{
  int i;
};

struct FieldAccessBar{
  int i;
  struct FieldAccessFoo* f;
};

struct FieldAccess{
};

void main(int argc,char** argv){
  int i;
  struct FieldAccessFoo* f;
  gc_add_root_node(&f);
  struct FieldAccessBar* b;
  gc_add_root_node(&b);
  f = (struct FieldAccessFoo*)gc_malloc(sizeof(struct FieldAccessFoo));
  f->i = 0;
  i = f->i;
  StaticJavaLib_assertTrue(f->i == 0);
  StaticJavaLib_assertTrue(i == 0);
  b = (struct FieldAccessBar*)gc_malloc(sizeof(struct FieldAccessBar));
  b->i = 1;
  i = b->i;
  StaticJavaLib_assertTrue(b->i == 1);
  StaticJavaLib_assertTrue(i == 1);
  b->f = f;
  b->f->i = 2;
  i = b->f->i;
  StaticJavaLib_assertTrue(b->f->i == 2);
  StaticJavaLib_assertTrue(i == 2);
  b->f->i = 3;
  f->i = b->f->i;
  StaticJavaLib_assertTrue(b->f->i == 3);
  StaticJavaLib_assertTrue(f->i == 3);
  b->f->i = 4;
  f = b->f;
  StaticJavaLib_assertTrue(f->i == 4);
  f->i = 5;
  b->f = f;
  StaticJavaLib_assertTrue(b->f->i == 5);
  b->f->i++;
  StaticJavaLib_assertTrue(b->f->i == 6);
  gc_free_root_node(&f);
  gc_free_root_node(&b);
  gc_recycle();
}
